import { _decorator, Color, color, Component, Label, Node, UITransform } from 'cc';
import { CardStruct } from './CardData';
const { ccclass, property } = _decorator;

@ccclass('CardItem')
export class CardItem extends Component {

    @property(Label)
    label_name: Label = null;
    @property(Label)
    label_star: Label = null;

    data: CardStruct = null;

    setData(data: CardStruct) {
        this.node.getComponent(UITransform).setContentSize(200,200)

        this.data = data;
        this.label_name.string = data.name;
        let labelColor = ['#000000', '#0033FF', '#FF0014'];
        this.label_star.color = color(labelColor[data.star - 1]);
        this.label_star.string = `${data.star}星`;
    }
}


